package com.example.dormmanage.controller;

import com.example.dormmanage.entity.Room;
import com.example.dormmanage.entity.Student;
import com.example.dormmanage.service.impl.RoomService;
import com.example.dormmanage.view.ResultView;
import com.example.dormmanage.view.RoomDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/room")
@Api(tags = "宿舍管理")
@Slf4j
public class RoomController {

    @Autowired
    private RoomService roomService;

    @GetMapping("/{buildingId}")
    @ApiOperation("查询宿舍列表")
    public ResultView<List<RoomDto>> selectRoomList(@PathVariable Integer buildingId){
       return roomService.selectRoomList(buildingId);
    }

    @GetMapping("/student/{roomId}")
    @ApiOperation("查询宿舍成员列表")
    public ResultView<List<Student>> selectRoomMemberList(@PathVariable Integer roomId){
        return roomService.selectRoomMemberList(roomId);
    }

}
